package org.cyk.bilibili_json_read.cmd;

import org.json.JSONArray;
import org.json.JSONObject;
public class ReadJsonCmd {

    public  static String cmd(String jsonContent)  {
        try {
            StringBuilder builder = new StringBuilder();
            JSONObject jo = new JSONObject(jsonContent);
            JSONArray body = jo.getJSONArray("body");
            body.forEach(p -> {
                JSONObject bodyItem = new JSONObject(p.toString());
                builder.append((String) bodyItem.get("content"));
                builder.append("\n");
            });
            return builder.toString();
        } catch (Exception e) {
            System.err.println("[ReadJsonCmd.analysisContent()]: 文件读取异常！");
            throw new RuntimeException(e);
        }
    }

}
